import java.util.Scanner;

public class Demo1 {
    public static boolean fun(String[] array) {
        boolean fly = true;

        for(int i = 0; i < array.length - 1; i++) {
            if(array[i].compareTo(array[i+1]) > 0) {
                fly = false;
            }
        }

        return fly;
    }

    public static boolean sum(String[] array) {
        boolean fly = true;

        for(int i = 0; i < array.length - 1; i++) {
            if(array[i].length() > array[i+1].length()) {
                fly = false;
            }
        }

        return fly;
    }

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        String[] str = new String[n];

        for(int i = 0; i < n; i++) {
            str[i] = scan.next();
        }

        if(str.length == 1) {
            System.out.println("both");
        }

        boolean fly1 = fun(str);
        boolean fly2 = sum(str);

        if(fly1 && fly2) {
            System.out.println("both");
        }else if(fly1) {
            System.out.println("lexicographically");
        }else if(fly2){
            System.out.println("lengths");
        }else {
            System.out.println("none");
        }
    }
}
